//package com.plian.system.service.qg.chart.impl;
//
//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
//import com.plian.Tools.CollectionUtil;
//import com.plian.Tools.DateUtil;
//import com.plian.Tools.StringUtil;
//import com.plian.Tools.pagedata.PageData;
//import com.plian.system.dao.bt.baseinfo.BaseInfoDao;
//import com.plian.system.dto.qg.chart.MixedChartDTO;
//import com.plian.system.entity.fr.bulletin.BulletinValue;
//import com.plian.system.entity.fr.bulletin.NewBulletin;
//import com.plian.system.entity.pf.AppraisalIndex;
//import com.plian.system.entity.pm.property.PropertyBasics;
//import com.plian.system.entity.sys.Org;
//import com.plian.system.service.fr.bulletin.IBulletinValueService;
//import com.plian.system.service.fr.bulletin.INewBulletinService;
//import com.plian.system.service.pf.IAppraisalIndexService;
//import com.plian.system.service.pm.property.IPropertyBasicsService;
//import com.plian.system.service.qg.chart.IMixedChartService;
//import com.plian.system.service.sys.orgzation.IOrgService;
//import com.plian.system.vo.report.*;
//import lombok.AllArgsConstructor;
//import org.springframework.stereotype.Service;
//
//import java.math.BigDecimal;
//import java.math.RoundingMode;
//import java.util.*;
//import java.util.stream.Collectors;
//
///**
// * @Author: Take-off
// * @Description: TODO 混改图表
// * @Date: 2023/2/22 10:44 AM
// * @Version: 1.0
// **/
//@Service
//@AllArgsConstructor
//public class MixedChartServiceImpl implements IMixedChartService {
//
//    private final IAppraisalIndexService appraisalIndexService;
//
//    private final INewBulletinService newBulletinService;
//
//    private final IBulletinValueService bulletinValueService;
//
//    private final IPropertyBasicsService propertyBasicsService;
//
//    private final IOrgService orgService;
//
//    private final BaseInfoDao baseInfoDao;
//
//    @Override
//    public ReportReturnVO getFinancialData(MixedChartDTO dto){
//        ReportReturnVO reportReturn = new ReportReturnVO();
//        List<Map<String, Object>> reportValues = new ArrayList<>();
//        Integer dataType = dto.getDataType();
//        //产权 ——> 组织
//        List<Org> orgs = getOrgByProIds(dto.getMixedIds());
//
//        List<Date> dates = new ArrayList<>();
//        for (String date:dto.getDates()){
//            dates.add(DateUtil.parse(date,DateUtil.PATTERN_MONTH));
//        }
//        //快报主表
//        if (CollectionUtil.isNotEmpty(orgs)) {
//            List<String> orgIds = orgs.stream().map(Org::getId).collect(Collectors.toList());
//            List<NewBulletin> bulletins = newBulletinService.list(new LambdaQueryWrapper<NewBulletin>().in(NewBulletin::getOrgId, orgIds).in(NewBulletin::getReportTime, dates));
//            //添加去年12月份
//            List<Date> lastDates = new ArrayList<>();
//            for (String date:dto.getDates()){
//                String lastMonth = DateUtil.format(DateUtil.minusDays(DateUtil.parse(DateUtil.format(DateUtil.parse(date, DateUtil.PATTERN_MONTH), DateUtil.PATTERN_YEAR), DateUtil.PATTERN_YEAR), 1), DateUtil.PATTERN_MONTH);
//                lastDates.add(DateUtil.parse(lastMonth, DateUtil.PATTERN_MONTH));
//            }
//
//            bulletins.addAll(newBulletinService.list(new LambdaQueryWrapper<NewBulletin>().in(NewBulletin::getOrgId, orgIds).in(NewBulletin::getReportTime, lastDates)));
//            if (dataType == 1) {
//                //一利五率
//                List<AppraisalIndex> appraisalIndices = getProfitPercentage();
//                //获取快报指标
//                if (CollectionUtil.isNotEmpty(appraisalIndices)){
//                    //指标取值
//                    List<String> typeCodes = appraisalIndices.stream().filter(m -> Optional.ofNullable(m.getIsFormula()).isPresent() &&m.getIsFormula() == 0).map(AppraisalIndex::getCompleteFormula).collect(Collectors.toList());
//                    //快报值
//                    List<BulletinValue> bulletinValues = getBulletinValues(bulletins,typeCodes);
//                    if (CollectionUtil.isNotEmpty(bulletinValues)){
//                        //计算值
//                        reportValues = getReportValue(orgIds, orgs, bulletins, bulletinValues, dates, appraisalIndices);
//                    }
//                    reportReturn = getReportReturn(dates,dto.getDataType(), reportValues, appraisalIndices, null);
//                }
//            }else {
//                try {
//                    //快报指标
//                    List<PageData> appraisalIndices=baseInfoDao.findbyParentid("125");
//                    if (CollectionUtil.isNotEmpty(appraisalIndices)){
//                        List<String> typeCodes = appraisalIndices.stream().map(m -> m.getString("code")).collect(Collectors.toList());
//                        //快报值
//                        List<BulletinValue> bulletinValues = getBulletinValues(bulletins,typeCodes);
//                        if (CollectionUtil.isNotEmpty(bulletinValues)){
//                            //计算值
//                            reportValues = getBulletinReport(orgIds, orgs, bulletins, bulletinValues, dates, appraisalIndices,dto.getValueType());
//                        }
//                        reportReturn = getReportReturn(dates,dto.getDataType(), reportValues, null, appraisalIndices);
//                    }
//                } catch (Exception e) {
//                    e.printStackTrace();
//                }
//            }
//        }
//
//        return reportReturn;
//    }
//
//    @Override
//    public Map<String,String> getCodeNames(MixedChartDTO dto){
//        Map<String, String> codeNames = new HashMap<>();
//        if (dto.getDataType() == 1) {
//            //一利五率
//            List<AppraisalIndex> appraisalIndices = getProfitPercentage();
//            if (CollectionUtil.isNotEmpty(appraisalIndices)){
//                for (AppraisalIndex appraisalIndex:appraisalIndices){
//                    codeNames.put(appraisalIndex.getName(),appraisalIndex.getCompleteCode());
//                }
//            }
//        }else {
//            //快报指标
//            try {
//                List<PageData> appraisalIndices=baseInfoDao.findbyParentid("125");
//                appraisalIndices= appraisalIndices.stream().filter(m -> m.getString("orgCode").contains(DateUtil.format(DateUtil.now(), DateUtil.PATTERN_YEAR)))
//                        .sorted(Comparator.comparing(m -> m.getInteger("sortCode"))).collect(Collectors.toList());
//                if (CollectionUtil.isNotEmpty(appraisalIndices)){
//                    for (PageData pageData:appraisalIndices){
//                        codeNames.put(pageData.getString("name").trim(),pageData.getString("code"));
//                    }
//                }
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
//        }
//        return codeNames;
//    }
//
//    @Override
//    public ChartsVO getFinancialColumnar(MixedChartDTO dto){
//        //折线图
//        ChartsVO chartsVO = new ChartsVO();
//        //x轴
//        List<XAxisVO> xAxisVOList = new ArrayList<>();
//        XAxisVO xAxisVO = new XAxisVO();
//        List<String> xAxisVOData = new ArrayList<>();
//        xAxisVO.setData(xAxisVOData);
//        xAxisVOList.add(xAxisVO);
//        chartsVO.setXAxis(xAxisVOList);
//        //值
//        List<SeriesVO> seriesVOList = new ArrayList<>();
//        chartsVO.setSeries(seriesVOList);
//
//        //横坐标-组织名
//        List<String> orgNames = new ArrayList<>();
//        xAxisVO.setData(orgNames);
//
//        List<Map<String, Object>> values = getFinancialData(dto).getGrids().getData();
//        if (CollectionUtil.isNotEmpty(values)){
//            for (String month:dto.getDates()){
//                SeriesVO seriesVO = SeriesVO.builder().name(month).type("bar").build();
//                seriesVOList.add(seriesVO);
//                List<Object> data = new ArrayList<>();
//                seriesVO.setData(data);
//                for (Map<String, Object> value:values){
//                    //横坐标
//                    orgNames.add(value.get("orgName").toString());
//                    Object codeValue = value.get( dto.getNameCode()+ "_" + month);
//                    if (Optional.ofNullable(codeValue).isPresent()){
//                        data.add(codeValue.toString());
//                    }else {
//                        data.add(BigDecimal.ZERO);
//                    }
//                }
//            }
//
//        }
//
//        return chartsVO;
//    }
//
//    /**
//     * @Author: Take-off
//     * @Description: //TODO 构成财务数据报表
//     * @Date: 5:34 PM 2023/2/23
//     * @Param: [dto, valueList, appraisalIndices, pageDataList]
//     * @return: com.plian.system.vo.report.ReportReturnVO
//     **/
//    private ReportReturnVO getReportReturn(List<Date> dates,Integer dateType,List<Map<String, Object>> valueList,List<AppraisalIndex> appraisalIndices,List<PageData> pageDataList){
//        ReportReturnVO reportReturnVO = new ReportReturnVO();
//        ReportVO reportVO = new ReportVO();
//        reportVO.addHeader(HeaderVO.builder().key("index").title("序号").build())
//                .addHeader(HeaderVO.builder().key("orgName").title("企业名称").build());
//
//        if (dateType == 1){
//            //一利五率
//            getReportHeader(dates,appraisalIndices,reportVO);
//        }else {
//            //快报指标
//            getBulletinHeader(dates,pageDataList,reportVO);
//        }
//
//        reportVO.setData(valueList);
//        reportReturnVO.setGrids(reportVO);
//        return reportReturnVO;
//    }
//
//    /**
//     * @Author: Take-off
//     * @Description: //TODO 一利五率表头
//     * @Date: 10:56 AM 2023/2/23
//     * @Param: [dates, appraisalIndices, reportVO]
//     * @return: void
//     **/
//    private void getReportHeader(List<Date> dates, List<AppraisalIndex> appraisalIndices,ReportVO reportVO){
//        //排序
//        appraisalIndices = appraisalIndices.stream().filter(m -> Optional.ofNullable(m.getSort()).isPresent()).sorted(Comparator.comparing(AppraisalIndex::getSort)).collect(Collectors.toList());
//        for (AppraisalIndex appraisalIndex:appraisalIndices){
//            List<HeaderVO> dateHeader = new ArrayList<>();
//            for (Date date:dates){
//                String month = DateUtil.format(date, DateUtil.PATTERN_MONTH);
//                String codeKey = appraisalIndex.getCompleteCode() + "_" + month;
//                dateHeader.add(HeaderVO.builder().key(codeKey).title(month).build());
//            }
//            reportVO.addHeader(HeaderVO.builder().title(appraisalIndex.getName()).children(dateHeader).build());
//        }
//
//    }
//
//    /**
//     * @Author: Take-off
//     * @Description: //TODO 快报表头
//     * @Date: 11:03 AM 2023/2/23
//     * @Param: [dates, appraisalIndices, reportVO]
//     * @return: void
//     **/
//    private void getBulletinHeader(List<Date> dates, List<PageData> appraisalIndices,ReportVO reportVO){
//        //排序
//        appraisalIndices = appraisalIndices.stream().sorted(Comparator.comparing(m -> m.getInteger("sortCode"))).collect(Collectors.toList());
//        for (PageData appraisalIndex:appraisalIndices){
//            List<HeaderVO> dateHeader = new ArrayList<>();
//            for (Date date:dates){
//                String month = DateUtil.format(date, DateUtil.PATTERN_MONTH);
//                String typeCode = appraisalIndex.getString("code");
//                String codeKey = typeCode + "_" + month;
//                dateHeader.add(HeaderVO.builder().key(codeKey).title(month).build());
//            }
//            String name = appraisalIndex.getString("name");
//            reportVO.addHeader(HeaderVO.builder().title(name.trim()).children(dateHeader).build());
//        }
//
//    }
//
//    /**
//     * @Author: Take-off
//     * @Description: //TODO 计算快报值
//     * @Date: 10:40 AM 2023/2/23
//     * @Param: [orgIds, orgs, bulletins, bulletinValues, dates, appraisalIndices, dataType]
//     * @return: java.util.List<java.util.Map<java.lang.String,java.lang.Object>>
//     **/
//    private List<Map<String, Object>> getBulletinReport(List<String> orgIds, List<Org> orgs,List<NewBulletin> bulletins, List<BulletinValue> bulletinValues, List<Date> dates, List<PageData> appraisalIndices,String tableCode){
//        List<Map<String, Object>> valueList = new ArrayList<>();
//        //序号
//        int index = 1;
//        for (String orgId:orgIds) {
//            Map<String, Object> valueMap = new HashMap<>();
//
//            valueMap.put("index",index++);
//            //企业名称
//            List<Org> orgList = orgs.stream().filter(org -> orgId.equals(org.getId())).collect(Collectors.toList());
//            if (CollectionUtil.isNotEmpty(orgList)) {
//                valueMap.put("orgName", orgList.get(0).getName());
//            }
//            //直接取值 - 指标值
//            for (Date date:dates){
//                String year = DateUtil.format(date, DateUtil.PATTERN_YEAR);
//                List<PageData> indices = appraisalIndices.stream().filter(m -> m.getString("orgCode").contains(year)).collect(Collectors.toList());
//                if (CollectionUtil.isNotEmpty(indices)){
//                    for (PageData pd:indices){
//                        setDirectValue(date,pd,bulletins,orgId,bulletinValues,valueMap,tableCode);
//                    }
//                }
//            }
//            valueList.add(valueMap);
//        }
//        return valueList;
//    }
//
//    /**
//     * @Author: Take-off
//     * @Description: //TODO proId获取组织
//     * @Date: 9:59 PM 2023/2/22
//     * @Param: [proIds]
//     * @return: java.util.List<com.plian.system.entity.sys.Org>
//     **/
//    private List<Org> getOrgByProIds(List<String> proIds){
//        List<Org> orgList = new ArrayList<>();
//        List<PropertyBasics> propertyBasics = propertyBasicsService.listByIds(proIds);
//        if (CollectionUtil.isNotEmpty(propertyBasics)){
//            List<String> orgIds = propertyBasics.stream().map(PropertyBasics::getOrgId).filter(orgId -> Optional.ofNullable(orgId).isPresent()).collect(Collectors.toList());
//            if (CollectionUtil.isNotEmpty(orgIds)){
//                 orgList = orgService.listByIds(orgIds);
//            }
//        }
//        return orgList;
//    }
//
//    /**
//     * @Author: Take-off
//     * @Description: //TODO 计算一利五率值
//     * @Date: 9:36 PM 2023/2/22
//     * @Param: [orgIds, orgs, bulletins, bulletinValues, dates, appraisalIndices]
//     * @return: void
//     **/
//    private List<Map<String, Object>> getReportValue(List<String> orgIds, List<Org> orgs,List<NewBulletin> bulletins, List<BulletinValue> bulletinValues, List<Date> dates, List<AppraisalIndex> appraisalIndices){
//        List<Map<String, Object>> valueList = new ArrayList<>();
//        //直接取值
//        List<AppraisalIndex> directs = appraisalIndices.stream().filter(index -> Optional.ofNullable(index.getIsFormula()).isPresent() && index.getIsFormula() == 0).collect(Collectors.toList());
//        //公式
//        List<AppraisalIndex> formulas = appraisalIndices.stream().filter(index -> Optional.ofNullable(index.getIsFormula()).isPresent() && index.getIsFormula() == 1).collect(Collectors.toList());
//        //序号
//        int index = 1;
//        for (String orgId:orgIds){
//            Map<String, Object> valueMap = new HashMap<>();
//
//            valueMap.put("index",index++);
//            //企业名称
//            List<Org> orgList = orgs.stream().filter(org -> orgId.equals(org.getId())).collect(Collectors.toList());
//            if (CollectionUtil.isNotEmpty(orgList)){
//                valueMap.put("orgName",orgList.get(0).getName());
//            }
//            //直接取值 - 指标值
//            for (AppraisalIndex appraisalIndex:directs){
//                for (Date date:dates){
//                    setDirectValue(date,appraisalIndex,bulletins,orgId,bulletinValues,valueMap,"0");
//                }
//            }
//            // 计算取值
//            for (AppraisalIndex appraisalIndex:formulas){
//                for (Date date:dates){
//                    setFormulaValue(date,appraisalIndex,valueMap);
//                }
//            }
//            valueList.add(valueMap);
//        }
//        return valueList;
//    }
//
//    /**
//     * @Author: Take-off
//     * @Description: //TODO 获取一利五率指标
//     * @Date: 11:21 AM 2023/2/22
//     * @Param: []
//     * @return: java.util.List<com.plian.system.entity.pf.AppraisalIndex>
//     **/
//    private List<AppraisalIndex> getProfitPercentage(){
//        return appraisalIndexService.list(new LambdaQueryWrapper<AppraisalIndex>().eq(AppraisalIndex::getTableCode, "004").orderByAsc(AppraisalIndex::getSort));
//    }
//
//    /**
//     * @Author: Take-off
//     * @Description: //TODO 获取快报指标值
//     * @Date: 1:47 PM 2023/2/22
//     * @Param: [orgIds, dates, typeCodes]
//     * @return: java.util.List<com.plian.system.entity.fr.bulletin.BulletinValue>
//     **/
//    private List<BulletinValue> getBulletinValues(List<NewBulletin> bulletins,List<String> typeCodes){
//        List<BulletinValue> bulletinValues = new ArrayList<>();
//        if (CollectionUtil.isNotEmpty(bulletins)) {
//            bulletinValues = bulletinValueService.list(new LambdaQueryWrapper<BulletinValue>().in(BulletinValue::getTypeCode, typeCodes)
//                    .in(BulletinValue::getBulletinId, bulletins.stream().map(NewBulletin::getId).collect(Collectors.toList())));
//        }
//        return bulletinValues;
//    }
//
//    /**
//     * @Author: Take-off
//     * @Description: //TODO 计算公式取值
//     * @Date: 9:35 PM 2023/2/22
//     * @Param: [date, appraisalIndex, valueMap]
//     * @return: void
//     **/
//    private void setFormulaValue(Date date,AppraisalIndex appraisalIndex,Map<String, Object> valueMap){
//        String dateStr = DateUtil.format(date, DateUtil.PATTERN_MONTH);
//        String completeCode = appraisalIndex.getCompleteCode();
//        switch (completeCode){
//            case "K11":setEquityReturn("K2","KLAST3","K3",date,completeCode,valueMap);break;
//            case "K12":setReturn("K4","K5",date,completeCode,valueMap);break;
//            case "K13":setReturn("K6","K7",date,completeCode,valueMap);break;
//            case "K14":setReturn("K8","K5",date,completeCode,valueMap);break;
//            case "K15":setReturn("K9","K10",date,completeCode,valueMap);break;
//            default:break;
//        }
//    }
//
//    /**
//     * @Author: Take-off
//     * @Description: //TODO 计算净资产收益率
//     * @Date: 9:27 PM 2023/2/22
//     * @Param: [valueOne, valueTwo, valueThree, date, completeCode, valueMap]
//     * @return: void
//     **/
//    private void setEquityReturn(String valueOne,String valueTwo,String valueThree,Date date,String completeCode,Map<String, Object> valueMap){
//        String month = DateUtil.format(date, DateUtil.PATTERN_MONTH).split("-")[1];
//        String dateStr = DateUtil.format(date, DateUtil.PATTERN_MONTH);
//        valueOne = valueOne + "_" + dateStr;
//        valueTwo = valueTwo + "_" + dateStr;
//        valueThree = valueThree + "_" + dateStr;
//        String codeKey = completeCode + "_" + dateStr;
//        if (Optional.ofNullable(valueMap.get(valueOne)).isPresent() && Optional.ofNullable(valueMap.get(valueTwo)).isPresent()
//                && Optional.ofNullable(valueMap.get(valueThree)).isPresent()){
//            BigDecimal decimal = new BigDecimal(valueMap.get(valueOne).toString());
//            BigDecimal divide = (new BigDecimal(valueMap.get(valueThree).toString()).add(new BigDecimal(valueMap.get(valueTwo).toString()))).divide(new BigDecimal("2"), 4, RoundingMode.HALF_UP);
//            BigDecimal monthDivide = new BigDecimal(month).divide(new BigDecimal(12), 4, RoundingMode.HALF_UP);
//            if (divide.compareTo(BigDecimal.ZERO) >0){
//                BigDecimal multiply = (decimal.multiply(new BigDecimal(100)).divide(divide, 4, RoundingMode.HALF_UP)).multiply(monthDivide);
//                valueMap.put(codeKey,multiply.setScale(2,RoundingMode.HALF_UP).toPlainString());
//            }else {
//                valueMap.put(codeKey,null);
//            }
//        }else {
//            valueMap.put(codeKey,null);
//        }
//    }
//
//    /**
//     * @Author: Take-off
//     * @Description: //TODO 计算比率
//     * @Date: 9:33 PM 2023/2/22
//     * @Param: [valueOne, valueTwo, date, completeCode, valueMap]
//     * @return: void
//     **/
//    private void setReturn(String valueOne,String valueTwo,Date date,String completeCode,Map<String, Object> valueMap){
//        String dateStr = DateUtil.format(date, DateUtil.PATTERN_MONTH);
//        valueOne = valueOne + "_" + dateStr;
//        valueTwo = valueTwo + "_" + dateStr;
//        String codeKey = completeCode + "_" + dateStr;
//        if (Optional.ofNullable(valueMap.get(valueOne)).isPresent() && Optional.ofNullable(valueMap.get(valueTwo)).isPresent()){
//            BigDecimal decimalTwo = new BigDecimal(valueMap.get(valueTwo).toString());
//            if (decimalTwo.compareTo(BigDecimal.ZERO) >0){
//                BigDecimal multiply = (new BigDecimal(valueMap.get(valueOne).toString()).multiply(new BigDecimal("100"))).divide(decimalTwo, 4, RoundingMode.HALF_UP);
//                valueMap.put(codeKey,multiply.setScale(2,RoundingMode.HALF_UP).toPlainString());
//            }else {
//                valueMap.put(codeKey,null);
//            }
//        }else {
//            valueMap.put(codeKey,null);
//        }
//    }
//
//    /**
//     * @Author: Take-off
//     * @Description: //TODO 筛选value值，放入map中
//     * @Date: 2:47 PM 2023/2/22
//     * @Param: [date, appraisalIndex, bulletins, orgId, bulletinValues, valueMap]
//     * @return: void
//     **/
//    private void setDirectValue(Date date,AppraisalIndex appraisalIndex,List<NewBulletin> bulletins,String orgId,List<BulletinValue> bulletinValues,
//                          Map<String, Object> valueMap,String tableTypeCode){
//        String dateStr = DateUtil.format(date, DateUtil.PATTERN_MONTH);
//        String typeCode = appraisalIndex.getCompleteFormula();
//        String codeKey = appraisalIndex.getCompleteCode() + "_" + dateStr;
//        //快报主表
//        if (appraisalIndex.getType() == 1){
//            //取 去年12月的值
//            String lastMonth = DateUtil.format(DateUtil.minusDays(DateUtil.parse(DateUtil.format(date, DateUtil.PATTERN_YEAR), DateUtil.PATTERN_YEAR), 1), DateUtil.PATTERN_MONTH);
//            date = DateUtil.parse(lastMonth, DateUtil.PATTERN_MONTH);
//        }
//        String bulletinId = getBulletinId(bulletins, orgId, date,tableTypeCode);
//        setMap( bulletinId,bulletinValues, typeCode, codeKey,valueMap);
//    }
//
//    private void setDirectValue(Date date,PageData appraisalIndex,List<NewBulletin> bulletins,String orgId,List<BulletinValue> bulletinValues,
//                                Map<String, Object> valueMap,String tableTypeCode){
//        String dateStr = DateUtil.format(date, DateUtil.PATTERN_MONTH);
//        String typeCode = appraisalIndex.getString("code");
//        String codeKey = typeCode + "_" + dateStr;
//        //快报主表
//        String bulletinId = getBulletinId(bulletins, orgId, date,tableTypeCode);
//        setMap( bulletinId,bulletinValues, typeCode, codeKey,valueMap);
//    }
//
//    /**
//     * @Author: Take-off
//     * @Description: //TODO 放置map value值
//     * @Date: 10:32 AM 2023/2/23
//     * @Param: [bulletinId, bulletinValues, typeCode, codeKey, valueMap]
//     * @return: void
//     **/
//    private void setMap(String bulletinId,List<BulletinValue> bulletinValues,String typeCode,String codeKey,Map<String, Object> valueMap){
//        if (StringUtil.isNotBlank(bulletinId)){
//            List<BulletinValue> values = bulletinValues.stream().filter(value -> bulletinId.equals(value.getBulletinId()) && typeCode.equals(value.getTypeCode())).collect(Collectors.toList());
//            if (CollectionUtil.isNotEmpty(values)) {
//                BigDecimal yearAmount = values.get(0).getYearAmount();
//                if (Optional.ofNullable(yearAmount).isPresent()){
//                    valueMap.put(codeKey,yearAmount.toPlainString());
//                }else {
//                    valueMap.put(codeKey,null);
//                }
//            }else {
//                valueMap.put(codeKey,null);
//            }
//        }else {
//            valueMap.put(codeKey,null);
//        }
//    }
//
//    /**
//     * @Author: Take-off
//     * @Description: //TODO 返回快报主表Id
//     * @Date: 2:16 PM 2023/2/22
//     * @Param: [bulletins, orgId, date]
//     * @return: java.lang.String
//     **/
//    private String getBulletinId(List<NewBulletin> bulletins,String orgId,Date date,String tableTypeCode){
//        String bulletinId = "";
//        List<NewBulletin> bulletinList = bulletins.stream().filter(bulletin -> orgId.equals(bulletin.getOrgId()) && date.equals(bulletin.getReportTime())).collect(Collectors.toList());
//        if (CollectionUtil.isNotEmpty(bulletinList)){
//            List<NewBulletin> newBulletins = bulletinList.stream().filter(bulletin -> tableTypeCode.equals(bulletin.getTableTypeCode())).collect(Collectors.toList());
//            if (CollectionUtil.isNotEmpty(newBulletins)){
//                 bulletinId = newBulletins.get(0).getId();
//            }
//        }
//        return bulletinId;
//    }
//
//}
